var currentSlideId = 1;
var nextSlideCaption="";
var prevSlideCaption="";
var currentSlideCaption="";
 
var jsHeight = screen.height;
var pageWidth = parseInt(jsHeight*1.3333);
var screenHeight= jsHeight;
var captionHeight=parseInt(screenHeight*0.075);
var slideHeight=parseInt(screenHeight*0.85);
var footerHeight=parseInt(screenHeight*0.075);

var vidHeight = parseInt(slideHeight * 0.3);
var vidWidth = parseInt(vidHeight * 1.3333);

 //alert(screenHeight+" " +slideHeight+ " " +captionHeight+ " " +footerHeight + " " +parseInt(footerHeight*.15) + " " + captionHeight*.15);
function initialize(){
	//resize();
//=alert(slideHeight);
document.getElementById('slide_caption').style.height=captionHeight+"px";
document.getElementById('slides').style.height=slideHeight+"px";
document.getElementById('footer').style.height=footerHeight+"px";
document.getElementById('footer_logo').style.height=parseInt(footerHeight*0.50)+"px";


document.getElementById('wrapper').style.width=pageWidth+"px";
document.getElementById('footer').style.width=pageWidth+"px";
document.getElementById('slides').style.width=pageWidth+"px";
document.getElementById('slide_caption').style.width=pageWidth+"px";
//document.getElementById('hede_slide').style.height=slideHeight;

//document.getElementById('footer').style.padding=parseInt(footerHeight*.15)+"px";
//document.getElementById('hede_slide').style.height=slideHeight;document.getElementById('slide_caption').style.padding=parseInt(captionHeight*.15)+"px";
//document.getElementById('uni_logo').style.padding=parseInt(footerHeight*.15)+"px";


//document.getElementById('caption').style.display="none";


}
function processKeyEvent(eventType, event) {
	// MSIE hack
	/*if (window.event) {
		event = window.event;
	}
	* */
	
	   //try {

        if(event.altKey){
			if(eventType=="onkeydown"){
				if (event.keyCode=="71") {
					var slideNum=prompt("Go to slide:");
					if(slideNum && slideNum<=lastSlideId)
						changeSlide(slideNum);
				}
			}
		 }
        
        if(event.altKey){
			if(eventType=="onkeydown"){
				if (event.keyCode=="82") {
					changeHeight();
				}
			}
		 }

		//}

   // catch (e) {

   //     alert(e);

  //  }
//	alert(eventType);
	//    try {
	if(eventType=="onkeyup"){	
	
		if (event.keyCode == "39" || event.keyCode == "32" ) {
			changeSlide("next");
		}
		if (event.keyCode == "37") {
			changeSlide("prev");
		}

	}
//}
//catch(e){
//	alert(e);
//	}
  
 
};

function processKeyDown(event) {
	 processKeyEvent("onkeydown", event);
};
function processKeyUp(event) {
	 processKeyEvent("onkeyup", event);
};

function processKeyPress(event) {
	processKeyEvent("onkeypress", event);
};


function resize(){  
var frame = document.getElementById("slide2");  
var htmlheight = document.body.scrollheight;  
alert(htmlheight);
var windowheight = window.innerheight;  
if ( htmlheight < windowheight ) { document.body.style.height = windowheight + "px"; frame.style.height = windowheight + "px"; }  
else { document.body.style.height = htmlheight + "px"; frame.style.height = htmlheight + "px"; }  
} 


function hideElement(input) {
	document.getElementById(input).style.display = "none";
}

function showElement(input) {
	document.getElementById(input).style.display = "block";
}

function changeSlide(input) {
	
	var nextSlideID = parseInt(currentSlideId) + 1;
	var previousSlideID = parseInt(currentSlideId) - 1;
	
	if(input=="next"){
		if(nextSlideID<=lastSlideId){
			setCaption(slideCaption[nextSlideID]);
			hideElement(currentSlideId);
			showElement(nextSlideID);
			currentSlideId = nextSlideID;
			
		}
	}
	else if(input=="prev"){
		
		if(previousSlideID>=1){
			setCaption(slideCaption[previousSlideID]);
			hideElement(currentSlideId);
			showElement(previousSlideID);
			currentSlideId = previousSlideID;
		}
	}
	else{
		hideElement(currentSlideId);
		showElement(input);
		currentSlideId = input;
	}
	
	document.getElementById('pageNumber').innerHTML=currentSlideId+'/'+lastSlideId;
	
	
	
}

function setCaption(slideCaption){
	document.getElementById("caption_text").innerHTML=slideCaption;
	}

function changeHeight(){
	var heightInput=prompt("Change height \nCurrent height is:" + jsHeight +"px");
	if(heightInput){	
	var screenHeight=heightInput ;
	var captionHeight=parseInt(screenHeight*0.075);
	var slideHeight=parseInt(screenHeight*0.85);
	var footerHeight=parseInt(screenHeight*0.075);
	
	document.getElementById('slide_caption').style.height=captionHeight+"px";
	document.getElementById('slides').style.height=slideHeight+"px";
	document.getElementById('footer').style.height=footerHeight+"px";
	}
	
	
	}



function bpSize(){
	alert('testing...');
	}

function t(){
	alert('testing...');
	}



try{
document.onkeydown=processKeyDown;
document.onkeyup=processKeyUp;
document.onkeypress=processKeyPress;
}
catch(e){
	alert(e);
	}
 
